<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>用户列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="../.././css/font.css">
    <link rel="stylesheet" href="../.././css/xadmin.css">
    <script src="../../layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>系统消息</legend>
</fieldset>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">消息标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" required  lay-verify="required" placeholder="请输入消息标题" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">消息链接</label>
        <div class="layui-input-block">
            <input type="text" name="msgLink" required  lay-verify="required" placeholder="请输入消息链接" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">消息内容</label>
        <div class="layui-input-block">
            <textarea name="msgContext" placeholder="请输入消息内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="saveSystemMsg">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(saveSystemMsg)', function(data){
            layer.msg(JSON.stringify(data.field));
            $.ajax({
                url:"/api/systemMsg/addSystemMsg",
                method:'post',
                data:{
                    msgTitle : data.field.title,
                    msgContext : data.field.msgContext,
                    msgLink : data.field.msgLink,
                },
                success:function (data) {
                    if(data.code == 200){
                        layer.msg("保存成功")
                    }else{
                        layer.msg(data.msg);
                    }
                }
            })
            return false;
        });
    });
</script>

</body>
</html>